package com.gyf.bos.web.interceptor;

import com.gyf.bos.model.User;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import org.apache.struts2.ServletActionContext;

public class BOSLoginInterceptor extends MethodFilterInterceptor {
    @Override
    protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
        User loginUser = (User) ServletActionContext.getRequest().getSession().getAttribute("loginUser");
        if (loginUser == null){
            System.out.println("拦截路径:"+ServletActionContext.getRequest().getRequestURI());
            //未登录，跳转登录页面
            return "login";
        }
        return actionInvocation.invoke();
    }
}
